package com.cu.jiekong.frame.model;

import com.github.pagehelper.PageInfo;

import java.util.List;

public class PageRet extends Ret {

    private int total = 0;

    private int pageSize = 10;

    private int pageIndex = 0;

    public PageRet(boolean status) {
        super(status);
    }

    public PageRet(String code, String message) {
        super(code, message);
    }

    public PageRet(String code, String message, Object data) {
        super(code, message, data);
    }

    public PageRet(Object data) {
        super(data);
        if (data instanceof List) {
            total = ((List) data).size();
        }
    }

    /**
     * 分页返回内容构造方法
     *
     * @param pageInfo 分页内容
     */
    public PageRet(PageInfo pageInfo) {
        super(pageInfo.getList());

        pageIndex = pageInfo.getPageNum();
        pageSize = pageInfo.getPageSize();
        total = pageInfo.getSize();
    }
}
